package utils;

import java.io.InputStream;
import java.sql.Connection;
import java.sql.DriverManager;
import java.util.Properties;

public class DatabaseUtil {
    private static Properties properties = new Properties();

    static {
        try (InputStream input = DatabaseUtil.class.getClassLoader().getResourceAsStream("database.properties")) {
            properties.load(input);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public static Connection getConnection(String region) throws Exception {
        String url = properties.getProperty(region + ".db.url");
        String username = properties.getProperty(region + ".db.username");
        String password = properties.getProperty(region + ".db.password");
        return DriverManager.getConnection(url, username, password);
    }
}